package com.yz.lzq.liwushuo.ui.modules.home;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.yz.lzq.liwushuo.jsonbean.HomeFragmentTabLayoutBean;

import java.util.List;

/**
 * Created by Administrator on 2016/11/1.
 */

public class HomeFragmentPagerAdapter extends FragmentPagerAdapter {
    //填充fragment的数据源
    private List<Fragment> mList_Fragment = null;
    //Tablayout的标题
    private List<HomeFragmentTabLayoutBean.DataBean.CandidatesBean> mList = null;

    public HomeFragmentPagerAdapter(FragmentManager fm, List<HomeFragmentTabLayoutBean.DataBean.CandidatesBean> mList, List<Fragment> mList_Fragment) {
        super(fm);
        this.mList = mList;
        this.mList_Fragment = mList_Fragment;
    }


    public HomeFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return mList_Fragment.get(position);
    }

    @Override
    public int getCount() {
        return mList_Fragment.size();
    }

    /**
     * 返回Tablayout的标题
     *
     * @param position
     * @return
     */
    @Override
    public CharSequence getPageTitle(int position) {
        if (position == 0) {
            return "精品";
        }
        return mList.get(position-1).getName();
    }
}
